package com.fenghongzhang.day003;

public class User {
    private String name;
    private String address;
    private String email;

    public User() {
    }

    public User(String name, String address) {
        this.name = name;
        this.address = address;
    }

    //为了构造User对象而存在.
    public static class Builder{
        private String name;
        private String address;
        private String email;


        //本来的写法
//        public void setName(String name) {
//            this.name = name;
//        }
        public Builder setName(String name){
            this.name = name;
            return this;
        }
        public Builder setAddress(String address){
            this.address = address;
            return this;
        }

        //实际用来创造User对象的方法
        public User build() {
            User user = new User();
            user.name = this.name;
            return user;
        }

    }



}
